/* 区域及经销商选择相关js */
var LalerLevel = new Array();
function initArrayLevel(){
    
    var temp = ['20000000000020','10000000000391','助理网销主管'];
    LalerLevel.push(temp);
    
    var temp = ['10000004','10000000000351','助理销售顾问'];
    LalerLevel.push(temp);
    
    var temp = ['20000000000061','10000000000434','一级展厅经理'];
    LalerLevel.push(temp);
    
    var temp = ['30000004','10000000000431','一级客服经理'];
    LalerLevel.push(temp);
    
    var temp = ['20000000000040','10000000000392','网络推广专员'];
    LalerLevel.push(temp);
    
    var temp = ['10000002','10000000000432','一级销售经理'];
    LalerLevel.push(temp);
    
    var temp = ['20000000000080','10000000000435','一级内训师'];
    LalerLevel.push(temp);
    
    var temp = ['10000010','10000000000433','一级市场经理'];
    LalerLevel.push(temp);
    
    var temp = ['10000004','10000000000352','一级销售顾问'];
    LalerLevel.push(temp);
    
    var temp = ['20000000000020','10000000000411','一级网销主管'];
    LalerLevel.push(temp);
    
    var temp = ['20000000000020','10000000000412','二级网销主管'];
    LalerLevel.push(temp);
    
    var temp = ['10000004','10000000000371','二级销售顾问'];
    LalerLevel.push(temp);

    changeSelid();
}

function changeSelid(){
    var CON_SLID = '0';
    var objSelect = document.FRM.CON_ROLE_TYPE;
    var objSelect1 = document.FRM.CON_SLID;
    objSelect1.options.length = 0;
    var varItem = new Option("-请选择-",""); 
    objSelect1.options.add(varItem);
    for(var i = 0; i < LalerLevel.length; i ++){
        var temp = LalerLevel[i];
        if(objSelect.value == temp[0]){
             var varItem = new Option(temp[2],temp[1]); 
             if(temp[1] == CON_SLID){
                varItem.selected=true;
             }
             objSelect1.options.add(varItem);
        }
    };
    $(objSelect1).select2();
}

$(function(){
    App.init();
    if (jQuery().datepicker) {
        $('.date-picker').datepicker({
            language:"zh-CN",
            rtl: App.isRTL(),
            autoclose: true
        });
    }
    $("select.form-control").select2();
    //岗位类型等级联动
    initArrayLevel();
    $('#CON_ROLE_TYPE').on('change', function(){
        changeSelid();
    });

    // 点击审核通过及审核驳回没选中的提示
    $( '#checkPass, #checkRefuse' ).on('click', function(){
        var len = $( '#custList > tbody' ).find( ':checkbox:checked' ).size();
        if( len === 0 ){
            $.Alert( '没有选择销售顾问信息！' );
        };
    });

})